/*
 * urlFile.h
 *
 *  Created on: Apr 30, 2011
 *      Author: xrose
 */

#ifndef URLFILE_H_
#define URLFILE_H_
#include <iostream>
#include <fstream>
#include <string>
#include "httpConnections.h"
#include "Url.h"
#include "thrdStruct.h"
using namespace std;

class urlFile{
public:
	urlFile();
	urlFile(Url url);
	urlFile(Url url, string filename);
	/*Destructor*/
	~urlFile();

	/**
	 * method open()
	 */
	bool open();
	/**
	 * method: write()
	 * write the buffer to HDD
	 */
	long write(thrdStruct &rec);
	/**
	 * method close()
	 * close the file
	 */
	bool close();
	/**
	 * method getSize()
	 */
	unsigned long getSize();
	/**
	 * method isOpen()
	 */
	bool isOpen();
private:
	unsigned long findFileSize();
	string _filename;
	Url _url;
	unsigned long _curPos;
	unsigned long _size;
	bool _isOpen;
	ofstream _diskFile;
};

#endif /* URLFILE_H_ */
